﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Kinect_Interface_Prototype_1.Kinect_MediaPlayer
{
    public class SpecialLabel : Label
    {
        private string originalText = String.Empty;
        private int count = 0;

        public SpecialLabel()
        {

        }

        protected override void OnSizeChanged(EventArgs e)
        {
            if (this.Width >= 285)
            {
                count++;

                if (count == 1)
                    Text = originalText.Substring(0, originalText.Length - 3) + "...";
                else
                    Text = originalText.Substring(0, originalText.Length - 3 - (count-1)) + "...";
                
            }

            base.OnSizeChanged(e);
        }

        protected override void OnTextChanged(EventArgs e)
        {
            if (!Text.Contains("..."))
                originalText = Text;
            base.OnTextChanged(e);
        }
    }
}
